#include "msgqueue.h"

int Messagelist::pushmsg(const Message& msgin)
{
    if(maxNodeNum < curNodeNum)
	{
	    return RNLC_FAIL;
	}
	msgNodes add;
	add.p_curmsg = msgin;
	add.next = NULL;
	if(curNodeNum == 0)
	{
	    firstNode = &add;
		tailNode = firstNode;
		firstNode->next = NULL;
		
	}
	else
	{
	    tailNode->next = &add;
		
	}
	curNodeNum++;
    return RNLC_SUCC;
}

int Messagelist::popmsg(Message& msgout)
{
    if(curNodeNum == 0 ||firstNode == NULL)
	{
	    return RNLC_FAIL;
	}
	msgout = firstNode->p_curmsg;
	msgNodes *toDelNode;
	toDelNode = firstNode;
	firstNode = firstNode->next;
	delete toDelNode;
	curNodeNum--;
	if(0 == curNodeNum)
	{
	    tailNode = NULL;
	}
	return RNLC_SUCC;
}	

	
	







